package com.yao.springcloud;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 
 * @Description: 服务提供者 application service
 * @author yaoym
 * @date 2017年12月26日 下午3:34:30
 * @version V1.0
 */
@RestController
//@EnableDiscoveryClient
@SpringBootApplication
public class ServiceHiApplication {

	private static final Logger logger = LoggerFactory.getLogger(ServiceHiApplication.class);

	@Value("${spring.application.name}")
	private String applicationName;

	@Value("${server.port}")
	private String port;

	public static void main(String[] args) {
		SpringApplication.run(ServiceHiApplication.class, args);
	}

	@Bean
	public CommandLineRunner runner() {
		logger.info("===========服务[{} {}]启动完成===========", applicationName, port);
		return null;
	}

	@RequestMapping(value = "/hi", method = RequestMethod.GET)
	public String hi(@RequestParam String name, HttpServletRequest request) {
		System.out.println("===12222222222=2=2");
		request.setAttribute("say", "+=[===============");
		
		return "!!!!hello, " + name + " i'm [ServiceHi] and port:" + port;
	}

}
